<!--sidebar-menu-->
<div id="sidebar" class="clearfix"><!-- <a href="#" class="visible-phone"><i class="icon icon-home"></i> Dashboard</a> -->
  <ul style="display: block;">
  {% include "common/menu.html" %}
  </ul>
</div>
<!--end sidebar-menu-->

<div id="content">
  
    <div class="container-fluid" style="padding: 0;">

      <div class="widget-box tab-tabs" >
          <div class="widget-title">
              <ul class="nav nav-tabs">
                  {% include "common/tab.html" %}
              </ul>
          </div>
          <div id="encryptionDIV" class="widget-content tab-content hidden">
            <div id="tab1" class="tab-pane active">
              <div class="container-fluid">
                  <!--<div class="row-fluid" style="margin: 20px 0;overflow: hidden;">-->
                      <!--<span style="font-size:20px;">“托”账号：此类账号送出的礼物等，计入成长值， 不计入收益</span>-->
                  <!--</div>-->
                <div class="row-fluid" style="margin: 20px 0;overflow: hidden;">
                  <form id="fiamlyform" class="form-search">
                    <span class="find-search pull-right">
                    <i class="icon-search icon-on-right bigger-110"></i>
                        <input name="order" type="hidden" value="0">
                    <input name="name" type="text" placeholder="用户名（uid）或昵称" >
                    <button id="btn_search" type="button" class="btn btn-purple">搜索</button>
                    </span>
                  </form>
                </div>

                  {% include "common/pagination.html" %}

                <div class="row-fluid">
                  <table id="tableList" class="table with-check table-purple">
                    <thead>
                      <tr>
                        <th>uid</th>
                        <th>昵称</th>
                        <th class="cursor" onclick="tableOrderClick('fiamlyform',1,getDataList)">富家等级&uarr;&darr;</th>
                        <th class="cursor" onclick="tableOrderClick('fiamlyform',3,getDataList)">最后一次聊天&uarr;&darr;</th>
                        <th></th>
                      </tr>
                    </thead>
                    <tbody>

                    </tbody>
                  </table>
                </div>

              </div>
            </div>
            
         </div>
        </div>
    
    </div>
            
    
</div>
<div id="enterPwd" style="display:none">
    <!--class="ui-dialog"-->
    <form id="enterPwdForm">
        <div>
            密码：
            <input type="password" value='' id="pwd"></div>
        <input id='hideuid' type="hidden"></form>
</div>
<script type="text/javascript">
    $('#enterPwd').on('keypress',function(e){
        e = e || window.event;
        if(13 == e.keyCode){
            var uid = $("#hideuid").attr('data');
            aa(uid);
            e.returnValue = false
            return false
        }
    });
    var uid = '{{info['uid']}}';
    enterPwd(uid);
    function enterPwd(uid){
        var postData = {};
        postData.type = 0;
        $.ajax({
            type:"POST",
            data:postData,
            url:'/ajax/checkHasAuth',
            dataType:'json',
            success:function(res){
                if(res.code == 0){
                    $("#encryptionDIV").removeClass('hidden');
                }else{
                    // var pwd = window.prompt("输入密码", "");
                    // aa(uid,pwd);
                    $('#enterPwd').dialog({
                        autoOpen:true,
                        width:320,
                        height:180,
                        title:'输入密码',
                        resizable:false,
                        modal:true,
                        open:function(){
                            $('#hideuid').attr('data',uid);
                        },
                        buttons: {
                            "确定": function () {
                                // $(".ui-dialog-titlebar-close").click();
                                aa(uid);
                            }
                        }
                    });
                }
            }
        });
    }
    function aa(uid,pwd){
        var data={};
        data.pwd = $('#pwd').val();
        data.type = 0;
        $.ajax({
            type:"POST",
            data:data,
            url:'/ajax/checkAnchorPwd',
            dataType:'json',
            success:function(res){
                if(res.code == 0){
                    location.reload();
                }else{
                    if(confirm(res.info) == false){
                        $("#encryptionDIV").addClass('hidden');
                    }else{
                        $("#encryptionDIV").addClass('hidden');
                    }
                }
            }
        });
    }
</script>



<script type="text/javascript">

$(function(){
    
  getDataList();
});

var btn_search=global.doc('btn_search');
utils.addEvent(btn_search,'click',function(){
    getDataList();
});

function tableOrderClick(doc,type,callback){
    var form= global.doc(doc),
            value=form.order.value;
    if(type>4){
        if(value==5){
            form.order.value=6;
        }else{
            form.order.value=5;
        }
    }else if(type>2){
        if(value==3){
            form.order.value=4;
        }else{
            form.order.value=3;
        }
    }else if(type>0){
        if(value==1){
            form.order.value=2;
        }else{
            form.order.value=1;
        }
    }else{
        form.order.value=0;
    }
    callback();
}

function getDataList(index){
    var form=global.doc('fiamlyform');
    var data={};
    data.name=form.name.value;
    data.sort=form.order.value;;
    data.page=index||1;
    data.pageSize=global.pageSize;
    $.ajax({
        type:"POST",
        data:data,
        url:'/ajax/chatRecordList',
        dataType:'json',
        success:function(res){
            var data=res.data;
            var tableList=document.getElementById("tableList");
            var tbody= tableList.getElementsByTagName('tbody')[0];
            dataTable.clearData(tbody);

            var count=document.getElementById('count');
            count.innerHTML=data.count;

            for(var i=0;i<data.list.length;i++){
                addRow(tbody,data.list[i]);
            }
            if(!index||index==0){
                utilsPagination("#pagination",data.count,global.pageSize,function(page_index,jq){
                    page_index+=1;
                    getDataList(page_index);
                });
            }
        }

    });
}


function addRow(table,data){

  var row=table.insertRow();
  var cell=row.insertCell(0);
  var cell1=row.insertCell(1);
  var cell2=row.insertCell(2);
  var cell3=row.insertCell(3);
  var cell4=row.insertCell(4);

  var div=document.createElement("div"),
    img=document.createElement("img"),
    span=document.createElement("span");

    div.className="anchor-info";
    img.src=global.contract+data.avatar;
    span.innerHTML=data.uid;
    span.style.cssText="margin-left: 10px;";

    div.appendChild(img);
    div.appendChild(span);

    cell.appendChild(div);

    cell1.innerHTML=data.nickName;   

    cell2.innerHTML=data.name;
    cell3.innerHTML=data.lastTime;
    
    
    var a=document.createElement("a");
    a.href='/pull/accountinfo?uid='+data.uid;
    a.innerHTML="查看";
    a.className="a-edit font font18 cr-pe cursor-pointer";
    cell4.appendChild(a);
    return row;
}




  
</script>